<?php
/**
 * キャンペーンガール2012応募モデルクラス<br />
 *
 * @package apamanshop
 * @author H.Imamura
 * @copyright (c) 2012 SystemSoft Corp. All rights reserved
 */
class Inquiry_Model_Campaigngirl2012 extends Inquiry_Model_Apibase
{
	/**
	 * 応募ログ登録
	 *
	 * @return 
	 */
	public function insertEntryLog($params, $db)
	{
		$db_params = array();
		
		$sql  = "";
		$sql .= "insert into CAMPAIGN_USER.C2012_CAMPAIGNGIRL_ENTRY (";
		$sql .= "  CG12_ID";
		$sql .= ", CG12_NAME";
		$sql .= ", CG12_KANA";
		$sql .= ", CG12_ZIP";
		$sql .= ", CG12_ADDRESS";
		$sql .= ", CG12_TEL";
		$sql .= ", CG12_MOBILE";
		$sql .= ", CG12_CONTACT";
		$sql .= ", CG12_MAIL";
		$sql .= ", CG12_SEX";
		$sql .= ", CG12_BIRTHDAY";
		$sql .= ", CG12_AGE";
		$sql .= ", CG12_BLOOD";
		$sql .= ", CG12_HEIGHT";
		$sql .= ", CG12_WEIGHT";
		$sql .= ", CG12_BREAST";
		$sql .= ", CG12_WAIST";
		$sql .= ", CG12_HIP";
		$sql .= ", CG12_FOOT";
		$sql .= ", CG12_ACADEMIC";
		$sql .= ", CG12_CAREER";
		$sql .= ", CG12_ENTRY";
		$sql .= ", CG12_OFFICE";
		$sql .= ", CG12_HOBBY_SKILL";
		$sql .= ", CG12_ST_WK_POINT";
		$sql .= ", CG12_RESPECT";
		$sql .= ", CG12_INTEREST";
		$sql .= ", CG12_REASON";
		$sql .= ", CG12_PR";
		$sql .= ", CG12_PHOTO1";
		$sql .= ", CG12_PHOTO1_OLD";
		$sql .= ", CG12_PHOTO2";
		$sql .= ", CG12_PHOTO2_OLD";
		$sql .= ", CG12_ENTRY_DATE";
		$sql .= ", CG12_SITE_KBN";
		$sql .= ", CG12_DEL_FLG";
		$sql .= ") values (";
		$sql .= "  :id ";
		$sql .= ", :name ";
		$sql .= ", :kana ";
		$sql .= ", :zip ";
		$sql .= ", :address ";
		$sql .= ", :tel ";
		$sql .= ", :mobile ";
		$sql .= ", :contact ";
		$sql .= ", :mail ";
		$sql .= ", :sex ";
		$sql .= ", to_date(:birthday, 'yyyyMMdd') ";
		$sql .= ", :age ";
		$sql .= ", :blood ";
		$sql .= ", :height ";
		$sql .= ", :wdight ";
		$sql .= ", :breast ";
		$sql .= ", :waist ";
		$sql .= ", :hip ";
		$sql .= ", :foot ";
		$sql .= ", :academic ";
		$sql .= ", :career ";
		$sql .= ", :entry ";
		$sql .= ", :office ";
		$sql .= ", :hobby_skill ";
		$sql .= ", :st_wk_point ";
		$sql .= ", :respect ";
		$sql .= ", :interest ";
		$sql .= ", :reason ";
		$sql .= ", :pr ";
		$sql .= ", :photo1 ";
		$sql .= ", :photo1_old ";
		$sql .= ", :photo2 ";
		$sql .= ", :photo2_old ";
		$sql .= ", to_date(:entry_date, 'yyyyMMddhh24miss') ";
		$sql .= ", :site_kbn ";
		$sql .= ", :del_flg ";
		$sql .= ")";
		
		$db_params['id']           = $params['Id'];
		$db_params['name']         = $params['Name'];
		$db_params['kana']         = $params['Kana'];
		$db_params['zip']          = $params['Zip1'].'-'.$params['Zip2'];
		$db_params['address']      = $params['PrefStr'].$params['Address'];
		if (!empty($params['Tel1']) && !empty($params['Tel2']) && !empty($params['Tel3'])) {
			$db_params['tel']      = $params['Tel1'].'-'.$params['Tel2'].'-'.$params['Tel3'];
		} else {
			$db_params['tel']      = '';
		}
		if (!empty($params['Mobile1']) && !empty($params['Mobile2']) && !empty($params['Mobile3'])) {
			$db_params['mobile']   = $params['Mobile1'].'-'.$params['Mobile2'].'-'.$params['Mobile3'];
		} else {
			$db_params['mobile']   = '';
		}
		if (!empty($params['Contact1']) && !empty($params['Contact2']) && !empty($params['Contact3'])) {
			$db_params['contact']  = $params['Contact1'].'-'.$params['Contact2'].'-'.$params['Contact3'];
		} else {
			$db_params['contact']  = '';
		}
		$db_params['mail']         = $params['Mail'];
		$db_params['sex']          = $params['Sex'];
		$db_params['birthday']     = $params['Year'].$params['Month'].$params['Day'];
		$db_params['age']          = $params['Age'];
		$db_params['blood']        = $params['Blood'];
		$db_params['height']       = $params['Height'];
		$db_params['wdight']       = $params['Weight'];
		$db_params['breast']       = $params['Breast'];
		$db_params['waist']        = $params['Waist'];
		$db_params['hip']          = $params['Hip'];
		$db_params['foot']         = $params['Foot'];
		$db_params['academic']     = $params['Academic'];
		$db_params['career']       = $params['Career'];
		$db_params['entry']        = $params['Entry'];
		$db_params['office']       = $params['Office'];
		$db_params['hobby_skill']  = $params['HobbySkill'];
		$db_params['st_wk_point']  = $params['StWkPoint'];
		$db_params['respect']      = $params['Respect'];
		$db_params['interest']     = $params['Interest'];
		$db_params['reason']       = $params['Reason'];
		$db_params['pr']           = $params['Pr'];
		$db_params['photo1']       = $params['Photo1'];
		$db_params['photo1_old']   = $params['PhotoPath1'];
		$db_params['photo2']       = $params['Photo2'];
		$db_params['photo2_old']   = $params['PhotoPath2'];
		$db_params['entry_date']   = $params['EntryDateDb'];
		$db_params['site_kbn']     = $params['SiteKbn'];
		$db_params['del_flg']      = $params['DelFlg'];
		
		return $this->dbExecQuery($sql, $db_params, $db);
	}

	// ID取得
	public function selectEntryId($db)
	{
		$db_params = array();
		
		$sql  = "select nvl(max(CG12_ID),0)+1 as ID from CAMPAIGN_USER.C2012_CAMPAIGNGIRL_ENTRY";
		
		return $this->dbGetData($sql, $db_params, $db);
	}

}
?>
